#version 460

//GL_EXT_scalar_block_layout

#include "../project_matrix.glsl"
#include "../multi_color.glsl"
#include "../vertOut.glsl"



layout(location = 0) in vec2 inPos;
layout(location = 1) in vec2 inWeights;


layout(location = 1) out vec4 vColorA;
layout(location = 2) out vec2 vUV;
layout(location = 3) out float gap;



//vec2 pos[4] = {vec2(10.0, 10.0), vec2(100.0, 10.0), vec2(10.0, 100.0), vec2(100.0, 100.0)};

void main(void){
	//gl_Position = mat_ProjecView * mat_view * mat_Model[gl_InstanceIndex] * vec4(inPos, 0.0, 1.0);
	mat3x2 mat = m_LP_SD[gl_InstanceIndex];
	
	vec4 v = vec4(0.0, 0.0, 0.0, 1.0);
	
	vUV = inPos.xy;
	v.xy = (inPos.xy * mat[2].x) + (mat[1] * inWeights.xy);
	
	v.xy += mat[0];
	v.xy *= m_Scale;
	
	
	
	v.z = mat[2].y;

	gl_Position = mat_ProjecView * v;

	//vUV.y = mat[1].x / mat[1].y;
	//vUV *= mat[1];
	vUV.y *= mat[1].y;
	vUV += m_Loc;
	//vUV.y /= m_GradientNum;
	
	vColor = f_buildColor(InstanceColor[gl_InstanceIndex].x);
	vColorA = f_buildColor(InstanceColor[gl_InstanceIndex].y);
	gap = m_GradientNum*2;
	
	gl_PointSize = 4.0;
}


 